const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mylongitude:"",  //经度
    mylatitude:"",    //纬度
    addListShow:true,
    locationString:'',
    toView:'',
    mapId:"myMap",
    showView:true,
    showTitle:'',
    showAddress:'',
    showTime:'',
    markers:[
      {
        id:0,
        latitude:30.21205,
        longitude:103.87207,
        iconPath:'../static/dibiao.png',
        title:'1922彭山区锦江校外店',
        address:"四川省眉山市彭山区锦江校外商业街",
        time:"10:00-22:00",
        width:34,
        height:34,
      },
      {
        id:1,
        latitude:30.21739,
        longitude:103.87390,
        iconPath:'../static/dibiao.png',
        title:'1920彭山区锦江校内店',
        address:"四川省眉山市彭山县彭溪街道锦江学院内商业街3-105号",
        time:"10:00-22:50",
        width:34,
        height:34,
      },
      {
        id:2,
        latitude:30.19245,
        longitude:103.87255,
        iconPath:'../static/dibiao.png',
        title:'0111眉山彭山南巷街店',
        address:"四川省眉山市彭山县南县街113号",
        time:"10:10-21:20",
        width:34,
        height:34,
      },
      {
        id:3,
        latitude:30.19310,
        longitude:103.87253,
        iconPath:'../static/dibiao.png',
        title:'0499眉山市彭山北街店',
        address:"四川省眉山市彭山区北街12号",
        time:"10:10-21:00",
        width:34,
        height:34,
      },
      {
        id:4,
        latitude:30.21225,
        longitude:103.87085,
        iconPath:'../static/peisong.png',
        title:'您的外卖正在配送',
        width:32,
        height:32,
      },
    ],
    shoplist:[
      {
        id:"shop0",
        title:"1922彭山区锦江校外店",
        icon:"../static/open.png",
        shopping:"去下单>",
        address:"四川省眉山市彭山区锦江校外商业街",
        image:"../static/shoppingtime.png",
        time:"10:00-22:00",
        phone:"../static/phone.png"
     },
      {
        id:"shop1",
        title:"1920彭山区锦江校内店",
        icon:"../static/open.png",
        shopping:"去下单>",
        address:"四川省眉山市彭山县彭溪街道锦江学院内商业街3-105号",
        image:"../static/shoppingtime.png",
        time:"10:00-22:50",
        phone:"../static/phone.png"
    },
      {
        id:"shop2",
        title:"0111眉山彭山南巷街店",
        icon:"../static/open.png",
        shopping:"去下单>",
        address:"四川省眉山市彭山县南县街113号",
        image:"../static/shoppingtime.png",
        time:"10:10-21:20",
        phone:"../static/phone.png"
        },
        {
          id:"shop3",
          title:"0499眉山市彭山北街店",
          icon:"../static/open.png",
          shopping:"去下单>",
          address:"四川省眉山市彭山区北街12号",
          image:"../static/shoppingtime.png",
          time:"10:10-21:00",
          phone:"../static/phone.png"
        }
    ]
  },
  /**选择城市 */
  chooseCity:function(){

  },
/**返回上一页面
 * 如果有店铺地址信息清除,如果没有店铺地址信息则返回上一页面
 */
  backInterface:function(){
      this.setData({showView:true})
    /**返回上一页面 */
      wx.navigateBack({
        complete: (res) => {},
      })
  },
go:function(e){
    wx.switchTab({
      url: '../diancan/diancan',
    })
},
  /**获取标点数据 */
  markertap(e){
    var that=this
    var id=e.markerId
    var name=this.data.markers[id].title
 //   console.log(name)
    this.setData({
      storeName:name, //门店名称
      showDialog:true,
    })
  },
  toggleDialog:function(){
    this.setData({
      showDialog:false,
    })
  },
  markerShow:function(e){
    this.setData({
      showView:false,
      showTitle:this.data.markers[e.detail.markerId].title,
      showAddress:this.data.markers[e.detail.markerId].address,
      showTime:this.data.markers[e.detail.markerId].time
    })
    if(e.detail.markerId==4){
      this.setData({
        showView:true
      })
      wx.switchTab({
        url: '../order/order'
        // url:'../text5/text5'
      })
    }
    // console.log(this.data.markers[e.detail.markerId].title)
  },
  close:function (e) {
    this.setData({
      showView:true
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad:function (options) {
    var that=this;
    wx.getLocation({
      type:'wgs84',
      success(suc){
  //      console.log(suc);
        var olongitude=suc.longitude;
        var olatitude=suc.latitude;
        var speed=suc.speed;  //速度
        var accuracy=suc.accuracy;    //位置的精确度
        that.setData({
          mylongitude:olongitude,
          mylatitude:olatitude,
        });
      },
      fail:function(){
    //    console.log('获取坐标失败')
      }
    })
  },

/**显示对话框 */

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})